#ifndef NETDATA_H
#define NETDATA_H
#include <QTcpSocket>
#include <QHostAddress>
#include <QThread>
#include <QVector>
#include <QTimer>
#include <QMetaMethod>

class LinkNetThread : public QThread
{
    Q_OBJECT
public:
    explicit LinkNetThread();
protected:
    void run();
signals:
    void tim();
 private:
    QTimer *timer;
};


//设置为单例模式
class NetData :public QThread
{
    Q_OBJECT
public:
    static NetData *GetNetWork();//获取单例
    NetData(NetData &)=delete;
    NetData& operator=(NetData &)=delete;
    QVector<QString> GetNuber();

    bool IsLink();//连接状态
    bool Registerd(QString accounct,QString passwd);//注册请求
    bool Post(QString pass,QString acounct);//post请求
    bool Get(int size);//get请求
signals:
    void registed(bool ok);
   void posted(bool ok);
   void geted();
   void link_is_ok();
   void link_is_no();
private:
    NetData();
    ~NetData();
private:
static  NetData *Net;
   LinkNetThread t;
   QVector<QString> Number;
    bool start;
    bool password;
    QTcpSocket *Client;
    QHostAddress toAddress;
    quint16 toPort;};

inline QVector<QString> NetData::GetNuber()
{
    return Number;
}

inline bool NetData::IsLink()
{
    return start;
}
#endif // NETDATA_H
